package apis

import (
	"fmt"
	"mini-gde/pkg"
	"mini-gde/service"
	"net/http"

	"github.com/gin-gonic/gin"
)

func HelmInstall(c *gin.Context) {
	req := make(map[string][]string)
	c.BindJSON(&req)
	apps := req["apps"]

	var err error
	for _, app := range apps {
		fmt.Println(app)
		err = service.HelmPackageApps(app)
		err = service.HelmInstallApps(app)
	}
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"code": pkg.ERROR,
			"msg":  pkg.GetMsg(pkg.ERROR),
		})

	} else {

		c.JSON(http.StatusOK, gin.H{
			"code": pkg.SUCCESS,
			"msg":  pkg.GetMsg(pkg.SUCCESS),
		})
	}
}
